<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="page" uri="http://page/zrgk/fourth" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href=<%=basePath %>>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<link href="houtai/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="houtai/js/main.js"></script>
<script type="text/javascript" src="houtai/pages/js2/WdatePicker.js"></script>

<script type="text/javascript">
//单个删除
function delButton(){
	if(confirm("你确定要删除吗？")){
		alert("删除成功！");
	};
}

function resp(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
		var txt=xmlhttp.responseText;	
		 
		location.href="NoticeServlet?param="+"Notice";
}

}
//批量删除
function checkeDel(){
	var count=0;
	var list=new Array();
	var alls=document.getElementsByName("checkid");
			for(var i=0;i<alls.length;i++){
				if(alls[i].checked){
				list[count]=alls[i].value;
					count++;
				}		
			}
			if(count>0){
			
				if(confirm("确认要删除吗?")){
					xmlhttp=new XMLHttpRequest();
					xmlhttp.onreadystatechange=resp;
					xmlhttp.open("get","NoticeServlet?id="+list+"&param="+"alldelete", true);
					xmlhttp.send(null);
					//alert("删除成功!");
					 document.getElementById("allde").submit();
				}
				
			}else{
				alert("请选中要操作的项");
			}
}
//全选和全不选
function allCheck(){
	var alls=document.getElementsByName("checkid");
	var conterCheck=document.getElementById("checkbox1");
	for(var i=0;i<alls.length;i++){
		if(conterCheck.checked){
			alls[i].checked=true;
		}else{
			alls[i].checked=false;
		}
	}
}
//导出excel
	function expolExcel() {
 
	var count=new Array();
	var index=0;
	var alls = document.getElementsByName("checkid");
	for ( var i = 0; i < alls.length; i++) {
		if (alls[i].checked) {
			count[index]=alls[i].value;;
			index++;
		}
	}
	if (count.length>0) {
	
		   location.href="TestServlet?param=notice&noticeid="+count+"&time="+new Date().getTime();
		  
	}else {
		alert("请选中要操作的项");
	}
	
}

//全选后某个按钮取消选中,则全选按钮也取消选中
	function check(node) {
		var conterCheck = document.getElementById("checkbox1");
		if (!node.checked) {
			if (conterCheck.checked) {
				conterCheck.checked = false;
			}
		}

	}
function sub(){

document.ne.submit();

}


	function init() {
		if (<%=session.getAttribute("state") != null%>
	)
			document.getElementById("select2").value =<%=session.getAttribute("state")%>
	}
	window.onload = init;
</script>
</head>
<body>
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td style="height:25px; background-color:#f3f3f3; font-weight:bold" valign="top">
    &nbsp;&nbsp;&nbsp;&nbsp;当前位置：
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;soda创业教育平台&nbsp;&nbsp;
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;后台管理&nbsp;&nbsp;
    <img src="houtai/images/arrow.gif" align="absmiddle">&nbsp;&nbsp;soda公告管理</td>
  </tr>
  <tr>
    <td style="height:34px; background-image:url(houtai/images/main_header.gif); border-bottom:1px solid #cfd8e0; padding:0px">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20" height="34"><img src="houtai/images/main_headerL.gif" width="20" height="34"></td>
          <td style="color:#90c8e8;"><img src="houtai/images/icon_card.gif" width="16" height="16" align="absmiddle">&nbsp;&nbsp;<strong>soda公告管理</strong></td>
          <td align="right" class="white" style="padding-right:20px">
          <a href="Javascript:expolExcel()" class="barBtn"><img src="houtai/images/1.png" width="16" height="16" align="absmiddle"> 导出</a>
          <a href="houtai/pages/afficheManage/add.jsp" class="barBtn"><img src="houtai/images/5.png" width="16" height="16" align="absmiddle"> 添加</a>
          <a href="Javascript:checkeDel()" class="barBtn"><img src="houtai/images/6.png" width="16" height="16" align="absmiddle"> 删除</a>
          </td>
        </tr>
    </table></td>
  </tr>
  <form name="ff1" action="NoticeServlet?param=Notice" method="post">
  <tr>
    <td style="height:30px; background-color:#bddbff; border-bottom:1px solid #cfd8e0;"><table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
      <TR>
        <th width="10%" align="center">标题</th>
        <td width="20%" class="BGCgray"><input type="text" name="notTitle" id="textfield"  value="${sessionScope.sni.notTitle}"></td>
        <th width="10%" align="center">更新时间</th>
        <td width="20%" class="BGCgray"><input type="text" class="Wdate"name="updateTime" id="textfield" value="${sessionScope.sni.notUpdateTime}" onClick='WdatePicker({dateFmt:&quot;yyyy-MM-dd&quot;});'></td>
        <th width="10%" align="center">程度</th>
        <td width="20%" class="BGCgray"><select name="select2" id="select2">
          <option value="0">全部</option>
		  <option value="1">一般</option>
		  <option value="2">紧急</option>
		  <option value="3">非常紧急</option>
        </select></td>
        <th width="10%" align="center"><BUTTON style="HEIGHT:25px" onClick="javascript:document.ff1.submit()"><img src="houtai/images/btn_search.gif" width="16" height="16" align="absmiddle"> 查询</BUTTON></th>
        </TR>
        </form>
    </table></td>
  </tr>
  <tr>
    <td height="100%" valign="top">
    <div style="overflow:auto;height:100%; width:100%">
      <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
        <TR>
          <th align="center"><input type="checkbox" name="checkbox" id="checkbox1" onChange="allCheck()"></th>
          <th align="center">ID</th>
          <th align="center">标题</th>
          <th align="center">更新日期</th>
          <th align="center">公告级别</th>
          <th width="180" align="center">操作</th>
          </TR>
          
           
        	<c:forEach items="${notice}" var="n" varStatus="i">
 			<c:if test="${n.notDelete!=0 }">
       <TR>
          <TD align="center"><input type="checkbox"  value="${n.notId }" name="checkid" onclick="check(this)"></TD>
          <TD align="center">${ (page.page-1)*page.per+i.index+1}</TD>
          <TD align="left"><a href="NoticeServlet?Id=${n.notId}&param=showAllNotice" style="color:black;">${n.notTitle}</a></TD>
          <TD align="center">${n.notUpdateTime}</TD>
		  <TD align="center"><c:if test="${n.notLevel==1}">一般</c:if><c:if test="${n.notLevel==2}">紧急</c:if><c:if test="${n.notLevel==3}">非常紧急</c:if></TD>
          <TD width="180" align="center">
          	<BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('查看该信息？')) location.href='NoticeServlet?Id=${n.notId}&param=showAllNotice';else return;">查看</BUTTON> 
            <BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('编辑该信息？')) location.href='NoticeServlet?editId=${n.notId}&param=edit';else return;">编辑</BUTTON>
            <BUTTON style="height:21px; font-size:12px" onClick="javascript:if (confirm('删除该信息？'))location.href='NoticeServlet?id=${n.notId}&param=delete';else return;">删除</BUTTON>
		</TD>
        </TR>
		
        </c:if>
        </c:forEach>
	
      </table>
                <page:page pi="${page }" />
      
    </div>
  </td>
  </tr>
</table>
</body>
</html>